import request from '@/utils/request';
import { getCurrentInstance } from 'vue';
const errortips =
  getCurrentInstance()?.appContext.config.globalProperties.$errortips;

/**
 * 分页查询用户
 */
/* export async function get_order_list(params) {
  const res = await request.post('/order/sales/order_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
} */
//零售单列表
export async function get_order_list(params) {
  const res = await request.post('/order/sales/order_list', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
//零售单详情
export async function get_sales_detail(params) {
  const res = await request.post('/order/sales/detail', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
//整单退货
export async function order_refund(params) {
  const res = await request.post('/order/refund/order_refund', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
//单个退货
export async function item_refund(params) {
  const res = await request.post('/order/refund/item_refund', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
//零售单货品详情
export async function item_detail(params) {
  const res = await request.post('/order/sales/item_detail', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
//货品删除
export async function del_item(params) {
  const res = await request.post('/order/sales/del_item', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
//零售单删除
export async function del_all(params) {
  const res = await request.post('/order/sales/del', {
    ...params
  });
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
